home *** CD-ROM | disk | FTP | other *** search
/ Chip 2000 February / OpenLinux 2.3 CD.iso / live / usr / share / vim / syntax / tcl.vim < prev    next >
Encoding:
Text File  |  1999-08-10  |  13.7 KB  |  215 lines

  1. " Vim syntax file
  2. " Language:    TCL/TK
  3. " Maintainer:    Allan Kelly <Allan.Kelly@ed.ac.uk>
  4. " Original:    Robin Becker <robin@jessikat.demon.co.uk>
  5. " Version:      5.1(synched), 1998 April 1
  6. " Keywords TODO: format clock click anchor
  7.  
  8. " Remove any old syntax stuff hanging around
  9. syn clear
  10. set comments=:#
  11. " A bunch of useful keywords
  12. syn keyword tclStatement    proc global return lindex 
  13. syn keyword tclStatement    llength lappend lreplace lrange list concat incr 
  14. syn keyword tclStatement    upvar set
  15. syn keyword tclLabel        case default
  16. syn keyword tclConditional    if then else elseif switch
  17. syn keyword tclRepeat        while for foreach break continue 
  18. syn keyword tcltkSwitch    contained    insert create polygon fill outline tag
  19.  
  20. " WIDGETS
  21. " commands associated with widgets
  22. syn keyword tcltkWidgetSwitch contained background highlightbackground insertontime cget
  23. syn keyword tcltkWidgetSwitch contained selectborderwidth borderwidth highlightcolor insertwidth 
  24. syn keyword tcltkWidgetSwitch contained selectforeground cursor highlightthickness padx setgrid
  25. syn keyword tcltkWidgetSwitch contained exportselection insertbackground pady takefocus
  26. syn keyword tcltkWidgetSwitch contained font insertborderwidth relief xscrollcommand
  27. syn keyword tcltkWidgetSwitch contained foreground insertofftime selectbackground yscrollcommand
  28. syn keyword tcltkWidgetSwitch contained height spacing1 spacing2 spacing3
  29. syn keyword tcltkWidgetSwitch contained state tabs width wrap
  30. " button
  31. syn keyword tcltkWidgetSwitch contained command default 
  32. " canvas
  33. syn keyword tcltkWidgetSwitch contained closeenough confine scrollregion xscrollincrement yscrollincrement orient
  34. " checkbutton, radiobutton
  35. syn keyword tcltkWidgetSwitch contained indicatoron offvalue onvalue selectcolor selectimage state variable
  36. " entry, frame
  37. syn keyword tcltkWidgetSwitch contained show class colormap container visual
  38. " listbox, menu
  39. syn keyword tcltkWidgetSwitch contained selectmode postcommand selectcolor tearoff tearoffcommand title type
  40. " menubutton, message
  41. syn keyword tcltkWidgetSwitch contained direction aspect justify 
  42. " scale
  43. syn keyword tcltkWidgetSwitch contained bigincrement digits from length resolution showvalue sliderlength sliderrelief tickinterval to
  44. " scrollbar
  45. syn keyword tcltkWidgetSwitch contained activerelief elementborderwidth
  46. " image
  47. syn keyword tcltkWidgetSwitch contained delete names types create
  48. " variable reference
  49. syn match tclVarRef "$[a-zA-Z][a-zA-Z1-9_.]*"
  50. syn match tclVarRef "${[a-zA-Z][a-zA-Z1-9_.]*}"
  51. " menu, mane add
  52. syn keyword tcltkWidgetSwitch contained active end last none cascade checkbutton command radiobutton separator
  53. syn keyword tcltkWidgetSwitch contained activebackground actveforeground accelerator background bitmap columnbreak
  54. syn keyword tcltkWidgetSwitch contained font foreground hidemargin image indicatoron label menu offvalue onvalue
  55. syn keyword tcltkWidgetSwitch contained selectcolor selectimage state underline value variable
  56. syn keyword tcltkWidgetSwitch contained add clone configure delete entryget entryconfigure index insert invoke
  57. syn keyword tcltkWidgetSwitch contained post postcascade type unpost yposition activate
  58. "syn keyword tcltkWidgetSwitch contained 
  59. "syn match tcltkWidgetSwitch contained 
  60. syn region tcltkWidget matchgroup=tcltkWidgetColor start="\<button\>" matchgroup=NONE skip="^\s*$" end="]\|[^\\]*\s*$"he=e-1 contains=tclLineContinue,tcltkWidgetSwitch,tclString,tcltkSwitch,tclNumber,tclVarRef 
  61. syn region tcltkWidget matchgroup=tcltkWidgetColor start="\<scale\>" matchgroup=NONE skip="^\s*$" end="]\|[^\\]*\s*$"he=e-1  contains=tclLineContinue,tcltkWidgetSwitch,tclString,tcltkSwitch,tclNumber,tclVarRef 
  62.  
  63. syn region tcltkWidget matchgroup=tcltkWidgetColor start="\<canvas\>" matchgroup=NONE skip="^\s*$" end="]\|[^\\]*\s*$"he=e-1  contains=tclLineContinue,tcltkWidgetSwitch,tclString,tcltkSwitch,tclNumber,tclVarRef 
  64. syn region tcltkWidget matchgroup=tcltkWidgetColor start="\<checkbutton\>" matchgroup=NONE skip="^\s*$" end="]\|[^\\]*\s*$"he=e-1  contains=tclLineContinue,tcltkWidgetSwitch,tclString,tcltkSwitch,tclNumber,tclVarRef 
  65. syn region tcltkWidget matchgroup=tcltkWidgetColor start="\<entry\>" matchgroup=NONE skip="^\s*$" end="]\|[^\\]*\s*$"he=e-1  contains=tclLineContinue,tcltkWidgetSwitch,tclString,tcltkSwitch,tclNumber,tclVarRef 
  66. syn region tcltkWidget matchgroup=tcltkWidgetColor start="\<frame\>" matchgroup=NONE skip="^\s*$" end="]\|[^\\]*\s*$"he=e-1  contains=tclLineContinue,tcltkWidgetSwitch,tclString,tcltkSwitch,tclNumber,tclVarRef 
  67. syn region tcltkWidget matchgroup=tcltkWidgetColor start="\<image\>" matchgroup=NONE skip="^\s*$" end="]\|[^\\]*\s*$"he=e-1  contains=tclLineContinue,tcltkWidgetSwitch,tclString,tcltkSwitch,tclNumber,tclVarRef 
  68. syn region tcltkWidget matchgroup=tcltkWidgetColor start="\<listbox\>" matchgroup=NONE skip="^\s*$" end="]\|[^\\]*\s*$"he=e-1  contains=tclLineContinue,tcltkWidgetSwitch,tclString,tcltkSwitch,tclNumber,tclVarRef 
  69. syn region tcltkWidget matchgroup=tcltkWidgetColor start="\<menubutton\>" matchgroup=NONE skip="^\s*$" end="]\|[^\\]*\s*$"he=e-1  contains=tclLineContinue,tcltkWidgetSwitch,tclString,tcltkSwitch,tclNumber,tclVarRef 
  70. syn region tcltkWidget matchgroup=tcltkWidgetColor start="\<message\>" matchgroup=NONE skip="^\s*$" end="]\|[^\\]*\s*$"he=e-1  contains=tclLineContinue,tcltkWidgetSwitch,tclString,tcltkSwitch,tclNumber,tclVarRef 
  71. syn region tcltkWidget matchgroup=tcltkWidgetColor start="\<radiobutton\>" matchgroup=NONE skip="^\s*$" end="]\|[^\\]*\s*$"he=e-1 contains=tclLineContinue,tcltkWidgetSwitch,tclString,tcltkSwitch,tclNumber,tclVarRef 
  72. syn region tcltkWidget matchgroup=tcltkWidgetColor start="\<scrollbar\>" matchgroup=NONE skip="^\s*$" end="]\|[^\\]*\s*$"he=e-1  contains=tclLineContinue,tcltkWidgetSwitch,tclString,tcltkSwitch,tclNumber,tclVarRef 
  73. " These words are dual purpose.
  74. " match switches
  75. syn match tcltkWidgetSwitch contained "-text"hs=s+1
  76. syn match tcltkWidgetSwitch contained "-menu"hs=s+1
  77. syn match tcltkWidgetSwitch contained "-label"hs=s+1
  78. " match commands - 2 lines for pretty match.
  79. "variable
  80. " Special case - If a number follows a variable region, it must be at the end of
  81. " the pattern, by definition. Therefore, (1) either include a number as the region
  82. " end and exclude tclNumber from the contains list, or (2) make variable
  83. " keepend. As (1) would put variable out of step with everything else, use (2).
  84. syn region tcltkCommand matchgroup=tcltkCommandColor start="^\<variable\>" matchgroup=NONE skip="^\s*$" end="]\|[^\\]*\s*$"he=e-1  contains=tclLineContinue,tclString,tclNumber,tclVarRef,tcltkCommand
  85. syn region tcltkCommand matchgroup=tcltkCommandColor start="\s\<variable\>\|\[\<variable\>"hs=s+1 matchgroup=NONE skip="^\s*$" end="]\|[^\\]*\s*$"he=e-1  contains=tclLineContinue,tclString,tclNumber,tclVarRef,tcltkCommand
  86. " menu
  87. syn region tcltkWidget matchgroup=tcltkWidgetColor start="^\<menu\>" matchgroup=NONE skip="^\s*$" end="]\|[^\\]*\s*$"he=e-1  contains=tclLineContinue,tcltkWidgetSwitch,tclString,tcltkSwitch,tclNumber,tclVarRef 
  88. syn region tcltkWidget matchgroup=tcltkWidgetColor start="\s\<menu\>\|\[\<menu\>"hs=s+1 matchgroup=NONE skip="^\s*$" end="]\|[^\\]*\s*$"he=e-1  contains=tclLineContinue,tcltkWidgetSwitch,tclString,tcltkSwitch,tclNumber,tclVarRef 
  89. " label
  90. syn region tcltkWidget matchgroup=tcltkWidgetColor start="^\<label\>" matchgroup=NONE skip="^\s*$" end="]\|[^\\]*\s*$"he=e-1  contains=tclLineContinue,tcltkWidgetSwitch,tclString,tcltkSwitch,tclNumber,tclVarRef 
  91. syn region tcltkWidget matchgroup=tcltkWidgetColor start="\s\<label\>\|\[\<label\>"hs=s+1 matchgroup=NONE skip="^\s*$" end="]\|[^\\]*\s*$"he=e-1  contains=tclLineContinue,tcltkWidgetSwitch,tclString,tcltkSwitch,tclNumber,tclVarRef 
  92. " text
  93. syn region tcltkWidget matchgroup=tcltkWidgetColor start="^\<text\>" matchgroup=NONE skip="^\s*$" end="]\|[^\\]*\s*$"he=e-1  contains=tclLineContinue,tcltkWidget,tcltkWidgetSwitch,tcltkSwitch,tclNumber,tclVarRef,tclString 
  94. syn region tcltkWidget matchgroup=tcltkWidgetColor start="\s\<text\>\|\[\<text\>"hs=s+1 matchgroup=NONE skip="^\s*$" end="]\|[^\\]*\s*$"he=e-1  contains=tclLineContinue,tcltkWidget,tcltkWidgetSwitch,tclString,tcltkSwitch,tclNumber,tclVarRef 
  95.  
  96. " This isn't contained (I don't think) so it's OK to just associate with the Color group.
  97. " TODO: This could be wrong.
  98. syn keyword tcltkWidgetColor    toplevel
  99.  
  100.  
  101. syn region tcltkPackConf matchgroup=tcltkPackConfColor start="\<configure\>" matchgroup=NONE skip="^\s*$" end="]\|[^\\]*\s*$"he=e-1  contains=tclLineContinue,tcltkWidgetSwitch,tclString,tcltkSwitch,tcltkPackConfSwitch,tclNumber,tclVarRef keepend
  102. syn region tcltkPackConf matchgroup=tcltkPackConfColor start="\<cget\>" matchgroup=NONE skip="^\s*$" end="]\|[^\\]*\s*$"me=e-1  contains=tclLineContinue,tcltkWidgetSwitch,tclString,tcltkSwitch,tcltkPackConfSwitch,tclNumber,tclVarRef 
  103.  
  104.  
  105. " NAMESPACE
  106. " commands associated with namespace
  107. syn keyword tcltkNamespaceSwitch contained children code current delete eval
  108. syn keyword tcltkNamespaceSwitch contained export forget import inscope origin
  109. syn keyword tcltkNamespaceSwitch contained parent qualifiers tail which command variable
  110. syn region tcltkCommand matchgroup=tcltkCommandColor start="\<namespace\>" matchgroup=NONE skip="^\s*$" end="{\|}\|]\|\"\|[^\\]*\s*$"me=e-1  contains=tclLineContinue,tcltkNamespaceSwitch
  111.  
  112. " EXPR 
  113. " commands associated with expr
  114. syn keyword tcltkMaths    contained    acos    cos    hypot    sinh
  115. syn keyword tcltkMaths    contained    asin    cosh    log    sqrt
  116. syn keyword tcltkMaths    contained    atan    exp    log10    tan
  117. syn keyword tcltkMaths    contained    atan2    floor    pow    tanh
  118. syn keyword tcltkMaths    contained    ceil    fmod    sin
  119. syn region tcltkCommand matchgroup=tcltkCommandColor start="\<expr\>" matchgroup=NONE skip="^\s*$" end="]\|[^\\]*\s*$"me=e-1  contains=tclLineContinue,tcltkMaths,tclNumber,tclVarRef,tclString,tcltlWidgetSwitch,tcltkCommand,tcltkPackConf 
  120.  
  121. " format
  122. syn region tcltkCommand matchgroup=tcltkCommandColor start="\<format\>" matchgroup=NONE skip="^\s*$" end="]\|[^\\]*\s*$"me=e-1  contains=tclLineContinue,tcltkMaths,tclNumber,tclVarRef,tclString,tcltlWidgetSwitch,tcltkCommand,tcltkPackConf 
  123.  
  124. " PACK
  125. " commands associated with pack
  126. syn keyword tcltkPackSwitch    contained    forget info propogate slaves
  127. syn keyword tcltkPackConfSwitch    contained    after anchor before expand fill in ipadx ipady padx pady side
  128. syn region tcltkCommand matchgroup=tcltkCommandColor start="\<pack\>" matchgroup=NONE skip="^\s*$" end="]\|[^\\]*\s*$"he=e-1  contains=tclLineContinue,tcltkPackSwitch,tcltkPackConf,tcltkPackConfSwitch,tclNumber,tclVarRef,tclString,tcltkCommand keepend
  129.  
  130. " STRING
  131. " commands associated with string
  132. syn keyword tcltkStringSwitch    contained    compare first index last length match range tolower toupper trim trimleft trimright wordstart wordend
  133. syn region tcltkCommand matchgroup=tcltkCommandColor start="\<string\>" matchgroup=NONE skip="^\s*$" end="]\|[^\\]*\s*$"he=e-1  contains=tclLineContinue,tcltkStringSwitch,tclNumber,tclVarRef,tclString,tcltkCommand 
  134.  
  135. " ARRAY
  136. " commands associated with array
  137. syn keyword tcltkArraySwitch    contained    anymore donesearch exists get names nextelement size startsearch set
  138. " match from command name to ] or EOL
  139. syn region tcltkCommand matchgroup=tcltkCommandColor start="\<array\>" matchgroup=NONE skip="^\s*$" end="]\|[^\\]*\s*$"he=e-1  contains=tclLineContinue,tcltkArraySwitch,tclNumber,tclVarRef,tclString,tcltkCommand 
  140.  
  141. " LSORT
  142. " switches for lsort
  143. syn keyword tcltkLsortSwitch    contained    ascii dictionary integer real command increasing decreasing index
  144. " match from command name to ] or EOL
  145. syn region tcltkCommand matchgroup=tcltkCommandColor start="\<lsort\>" matchgroup=NONE skip="^\s*$" end="]\|[^\\]*\s*$"he=e-1  contains=tclLineContinue,tcltkLsortSwitch,tclNumber,tclVarRef,tclString,tcltkCommand 
  146.  
  147. syn keyword tclTodo contained    TODO
  148.  
  149.  
  150. " String and Character contstants
  151. " Highlight special characters (those which have a backslash) differently
  152. syn match   tclSpecial contained "\\\d\d\d\=\|\\."
  153. " A string needs the skip argument as it may legitimately contain \".
  154. " Match at start of line
  155. syn region  tclString          start=+^"+ end=+"+ contains=tclSpecial skip=+\\\\\|\\"+
  156. "Match all other legal strings.
  157. syn region  tclString          start=+[^\\]"+ms=s+1  end=+"+ contains=tclSpecial skip=+\\\\\|\\"+
  158.  
  159. syn match   tclLineContinue "\\\s*$"
  160.  
  161. "integer number, or floating point number without a dot and with "f".
  162. syn case ignore
  163. syn match  tclNumber        "\<\d\+\(u\=l\=\|lu\|f\)\>"
  164. "floating point number, with dot, optional exponent
  165. syn match  tclNumber        "\<\d\+\.\d*\(e[-+]\=\d\+\)\=[fl]\=\>"
  166. "floating point number, starting with a dot, optional exponent
  167. syn match  tclNumber        "\.\d\+\(e[-+]\=\d\+\)\=[fl]\=\>"
  168. "floating point number, without dot, with exponent
  169. syn match  tclNumber        "\<\d\+e[-+]\=\d\+[fl]\=\>"
  170. "hex number
  171. syn match  tclNumber        "0x[0-9a-f]\+\(u\=l\=\|lu\)\>"
  172. "syn match  tclIdentifier    "\<[a-z_][a-z0-9_]*\>"
  173. syn case match
  174.  
  175. syn region  tclComment        start="^[     ]*\#" end="$" contains=tclTodo
  176.  
  177. "syn sync ccomment tclComment
  178.  
  179. if !exists("did_tcl_syntax_inits")
  180.   let did_tcl_syntax_inits = 1
  181.   " The default methods for highlighting.  Can be overridden later
  182.   hi link tcltkSwitch        Special
  183.   hi link tclLabel        Label
  184.   hi link tclConditional    Conditional
  185.   hi link tclRepeat        Repeat
  186.   hi link tclNumber        Number
  187.   hi link tclError        Error
  188.   hi link tclStatement        Statement
  189.   " hi link tclStatementColor    Statement
  190.   hi link tclString        String
  191.   hi link tclComment        Comment
  192.   hi link tclSpecial        Special
  193.   hi link tclTodo        Todo
  194.   " Below here are the commands and their options.
  195.   hi link tcltkCommandColor    Statement
  196.   hi link tcltkWidgetColor      Structure
  197.   hi link tclLineContinue       WarningMsg
  198.   hi link tcltkStringSwitch    Special
  199.   hi link tcltkArraySwitch    Special
  200.   hi link tcltkLsortSwitch    Special
  201.   hi link tcltkPackSwitch    Special
  202.   hi link tcltkPackConfSwitch    Special
  203.   hi link tcltkMaths        Special
  204.   hi link tcltkNamespaceSwitch    Special
  205.   hi link tcltkWidgetSwitch    Special
  206.   hi link tcltkPackConfColor    Identifier
  207.   "hi link tcltkLsort        Statement
  208.   hi link tclVarRef             Identifier
  209. endif
  210.  
  211. let b:current_syntax = "tcl"
  212.  
  213. " vim: ts=8
  214.